package com.dongdongshop.mq;


import com.dongdongshop.service.ScoreService;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(consumerGroup = "consumer-group",topic = "tx-topic")
public class RocketMQConsumer implements RocketMQListener {

    @Autowired
    private ScoreService scoreService;

    @Override
    public void onMessage(Object o) {
        String message = (String) o;
        System.out.println(message);
        scoreService.insertScore(message);
    }


   // , RocketMQPushConsumerLifecycleListener
    /*@Override
    public void prepareStart(DefaultMQPushConsumer defaultMQPushConsumer) {

    }*/
}
